

<?php
Yii::app()->clientScript->registerScriptFile('js/highcharts.js', CClientScript::POS_END);
Yii::app()->clientScript->registerScriptFile('js/exporting.js', CClientScript::POS_END);
?>
<?php echo CHtml::submitButton('详细报告', array(
     'submit'=>Yii::app()->controller->createUrl('Btbatterys/details'
     		.'&'."redirect=1" 
	     	.'&'."select_unit=".Yii::app()->controller->select_unit
     		.'&'."select_maker=".Yii::app()->controller->select_maker
     		.'&'."select_size=".Yii::app()->controller->select_size
     		.'&'."select_timer=".Yii::app()->controller->select_timer
  
     		 ),
		'class'=>'button blue'
     // or simply
     //'submit'=>'mycontroller/myaction'
)); ?>
<?php echo CHtml::submitButton('数据导出', array(
     'submit'=>Yii::app()->controller->createUrl('Btbatterys/importdata'
			.'&'."redirect=1" 
     	    .'&'."select_unit=".Yii::app()->controller->select_unit
     		.'&'."select_maker=".Yii::app()->controller->select_maker
     		.'&'."select_size=".Yii::app()->controller->select_size
     		.'&'."select_timer=".Yii::app()->controller->select_timer
		),
		'class'=>'button blue'
     // or simply
     //'submit'=>'mycontroller/myaction'
)); ?>
<div id="container" style="min-width:400px;height:<?php echo ( count($dataSet) +1 ) / 2 * 400?>px;margin:0 auto;">
</div>
<script>




$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container'
            },
            title: {
                text: '电池组对比分类对比图'
            },
            xAxis: {
                categories: ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
            },
            tooltip: {
                formatter: function() {
                    var s;
                    if (this.point.name) { // the pie chart
                        s = ''+
                            this.point.name +': '+ this.y *100  + '%'  ;
                    } else {
                        s = ''+
                            this.x  +': '+ this.y;
                    }
                    return s;
                }
            },

            labels: {
                items: [
<?php  for ($i = 0; $i < count($dataSet)  ; $i++){	if($dataSet[$i]["red_n"]+ $dataSet[$i]["yellow_n"] +$dataSet[$i]["green_n"] == 0) continue;	?>                      
                        {
                   html:  <?php echo  "'".( !Yii::app()->controller->unit_visible_tag ? "" : 
                   			(Yii::app()->controller->group_option == 10 ? $dataSet[$i]["province_name"]:
                   			(Yii::app()->controller->group_option == 11 ? $dataSet[$i]["province_name"].$dataSet[$i]["city_name"]:
                   			(Yii::app()->controller->group_option == 12 ? $dataSet[$i]["province_name"].$dataSet[$i]["city_name"].$dataSet[$i]["county_name"]:
                   			(Yii::app()->controller->group_option == 13 ? $dataSet[$i]["province_name"].$dataSet[$i]["city_name"].$dataSet[$i]["county_name"].$dataSet[$i]["base_name"]: "所有数据")))))
		            		.(Yii::app()->controller->maker_visible_tag ? "-".$dataSet[$i]["manname"] : "")
		            		.(Yii::app()->controller->guige_visible_tag ? "-".$dataSet[$i]["BATTERYTYPE_V"] : "")
		            		.(Yii::app()->controller->time_visible_tag ? "-".$dataSet[$i]["SETUP_D"] : "").
                   "'"?> ,
                   style: {
                       left: 200 *<?php echo 2* ($i % 2)  ?> +　240,
                       top:     400 * <?php echo floor($i/2)    ?>    ,
                       color: 'black'
                   }
               },

  <?php  }	?>
               ]
           },
 
            series: [ 
<?php  for ($i = 0; $i < count($dataSet)  ; $i++){ if($dataSet[$i]["red_n"]+ $dataSet[$i]["yellow_n"] +$dataSet[$i]["green_n"] == 0) continue;	?>
{
    type: 'pie',
    name: '电池百分比',
    data: [{
        name:  '红色  ( '.concat(<?php echo $dataSet[$i]["red_n"]?> ).concat("组)"),
        y: <?php echo  number_format(  $dataSet[$i]["red_n"] /($dataSet[$i]["red_n"]+ $dataSet[$i]["yellow_n"] +$dataSet[$i]["green_n"] ), 4, '.', '')  ?>,
        color: '#EE0000' , 

			events : {
				click :	function(){
					//window.location.href = '/index.php?r=dictBattery/download';
					//http://localhost/yiifw/web/index.php?r=btBatterys/color
					window.location.href = 'http://localhost/yiifw/web/index.php?r=btBatterys/color&' + <?php echo "'".'status=2'.'&'."redirect=1" 
					     	.'&'."select_unit=".Yii::app()->controller->select_unit
				     		.'&'."select_maker=".Yii::app()->controller->select_maker
				     		.'&'."select_size=".Yii::app()->controller->select_size
				     		.'&'."select_timer=".Yii::app()->controller->select_timer
							.'&option_id='.
							(Yii::app()->controller->group_option == 10 ? $dataSet[$i]["province_id"]:
							(Yii::app()->controller->group_option == 11 ? $dataSet[$i]["city_id"]:
							(Yii::app()->controller->group_option == 12 ? $dataSet[$i]["county_id"]:
							(Yii::app()->controller->group_option == 13 ? $dataSet[$i]["base_id"]:
		            		(Yii::app()->controller->group_option == 1 ? $dataSet[$i]["man_id"]:   
		            		(Yii::app()->controller->group_option == 2 ? $dataSet[$i]["type_id"]:
		            		(Yii::app()->controller->group_option == 3 ? $dataSet[$i]["SETUP_D"]:
		            		"none")))))))."'" ?>    ;
				}
			},
			
    }, {
        name:  '黄色  ( '.concat(<?php echo $dataSet[$i]["yellow_n"]?> ).concat("组 )"),
        y: <?php echo  number_format( $dataSet[$i]["yellow_n"]  /($dataSet[$i]["red_n"]+ $dataSet[$i]["yellow_n"] +$dataSet[$i]["green_n"] ), 4, '.', '')  ?>,
        color: '#CDCD00' , 
		events : {
			click :	function(){
				//window.location.href = '/index.php?r=dictBattery/download';
				
				window.location.href = 'http://localhost/yiifw/web/index.php?r=btBatterys/color&' + <?php echo "'".'status=1'.'&'."redirect=1" 
					     	.'&'."select_unit=".Yii::app()->controller->select_unit
				     		.'&'."select_maker=".Yii::app()->controller->select_maker
				     		.'&'."select_size=".Yii::app()->controller->select_size
				     		.'&'."select_timer=".Yii::app()->controller->select_timer
							.'&option_id='.
							(Yii::app()->controller->group_option == 10 ? $dataSet[$i]["province_id"]:
							(Yii::app()->controller->group_option == 11 ? $dataSet[$i]["city_id"]:
							(Yii::app()->controller->group_option == 12 ? $dataSet[$i]["county_id"]:
							(Yii::app()->controller->group_option == 13 ? $dataSet[$i]["base_id"]:
		            		(Yii::app()->controller->group_option == 1 ? $dataSet[$i]["man_id"]:  
		            		(Yii::app()->controller->group_option == 1 ? $dataSet[$i]["type_id"]:
		            		(Yii::app()->controller->group_option == 3 ? $dataSet[$i]["SETUP_D"]:
		            		"none")))))))."'" ?>    ;
			}
		},
    
         
    }, {
        name:  '绿色  ( '.concat(<?php echo $dataSet[$i]["green_n"]?> ).concat("组 )"), 
        y: <?php echo number_format( $dataSet[$i]["green_n"] /($dataSet[$i]["red_n"]+ $dataSet[$i]["yellow_n"] +$dataSet[$i]["green_n"] ), 4, '.', '')  ?>,
        color: '#008B00' , 
		events : {
			click :	function(){
				//window.location.href = '/index.php?r=dictBattery/download';
				
				window.location.href = 'http://localhost/yiifw/web/index.php?r=btBatterys/color&' + <?php echo "'".'status=0'.'&'."redirect=1" 
					     	.'&'."select_unit=".Yii::app()->controller->select_unit
				     		.'&'."select_maker=".Yii::app()->controller->select_maker
				     		.'&'."select_size=".Yii::app()->controller->select_size
				     		.'&'."select_timer=".Yii::app()->controller->select_timer
							.'&option_id='.
							(Yii::app()->controller->group_option == 10 ? $dataSet[$i]["province_id"]:
							(Yii::app()->controller->group_option == 11 ? $dataSet[$i]["city_id"]:
							(Yii::app()->controller->group_option == 12 ? $dataSet[$i]["county_id"]:
							(Yii::app()->controller->group_option == 13 ? $dataSet[$i]["base_id"]:
		            		(Yii::app()->controller->group_option == 1 ? $dataSet[$i]["man_id"]:  
		            		(Yii::app()->controller->group_option == 1 ? $dataSet[$i]["type_id"]:
		            		(Yii::app()->controller->group_option == 3 ? $dataSet[$i]["SETUP_D"]:
		            		"none")))))))."'" ?>    ;
			}
		},
    
    }],
    center: [200 *<?php echo 2* ($i % 2)  ?> +　300,  400 * <?php echo floor($i/2)    ?>  + 200],
    size: 200,
    showInLegend: false,
    dataLabels: {
        enabled: true ,
        distance: 10 ,
        formatter: function() {
            // display only if larger than 1
            return  '<b>'+ this.point.name +':</b> '+ this.y *100 +'%'  ;
        }
    }
},
<?php  }	?>
]
        });
    });
    
});








</script>